﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DSD_CINE.Dominio;
using System.Data;
using System.Data.SqlClient;

namespace DSD_CINE.Persistencia
{
    public class CineDAO
    {
        public List<BE_CINE> ListarTodos() {
            List<BE_CINE> lstCinesBE = new List<BE_CINE>();
            BE_CINE beCine = null;
            String sSQL = "";
            sSQL = "set language spanish EXEC SP_CINES";
            using (SqlConnection con = new SqlConnection(ConexionUtil.Conexion)) {

                con.Open();
                using (SqlCommand com = new SqlCommand(sSQL, con)) {
                    using (SqlDataReader resultado = com.ExecuteReader()) {
                        while (resultado.Read())
                        {
                            beCine = new BE_CINE() {
                                Codcine = (string)resultado["cod_cine"],
                                Nombre = (string)resultado["nombre"]
                            };
                            lstCinesBE.Add(beCine);                           
                        }
                    
                    }
                
                }
                            
            }
            return lstCinesBE;
          
        }

    }
}